home *** CD-ROM | disk | FTP | other *** search
- /*
- * Writeoutput.c
- */
-
- #define QWriteoutput
-
- #include "QMain.h"
- #include "QWriteoutput.h"
- #include "QDataload.h"
- #include "QDisassemble.h"
-
- #include "hourglass.h"
- #include "osfile.h"
- #include "osfind.h"
- #include "osgbpb.h"
-
- /*
- * Selection is given by Selectionstart Selectionend, lword offsets
- * into the file Loadedfile. Savetype is Selected or All.
- */
-
- void Writeoutput(void)
- {
- os_f filehandle;
- byte word[4];
- int notread, i, j, k;
- char *disassembly;
- int dislength;
- char address[9], hexcode[9], asciicode[4], *end;
- int start, stop;
-
- hourglass_on();
- filehandle=osfind_openout(osfind_NO_PATH,filenameptr,NULL);
- if (Savetype==Selected) {
- start=Selectionstart;
- stop=Selectionend;
- } else {
- start=0;
- stop=Loadedsize/4;
- }
- for (i=start; i<stop; i++) {
- notread=osgbpb_read_at(Loadedfile,word,4,i*4);
- Disassemble(*((int *)word),(int *)(Baseaddress+i*4),
- &disassembly,&dislength);
- os_convert_hex8(Baseaddress+i*4,address,9,&end);
- os_convert_hex8(*((int *)word),hexcode,9,&end);
- for (j=0; j<4; j++) {
- asciicode[j]=((word[j]>31) && (word[j]<127))?((char)word[j]):'.';
- }
- j=FALSE;
- for (k=1; k<5; k++) {
- if (k==seqinfo[0].number) {
- if (j) osgbpb_write(filehandle, (byte *) " : ", 3);
- osgbpb_write(filehandle, (byte *) address, 8);
- j=TRUE;
- }
- if (k==seqinfo[1].number) {
- if (j) osgbpb_write(filehandle, (byte *) " : ", 3);
- osgbpb_write(filehandle, (byte *) asciicode, 4);
- j=TRUE;
- }
- if (k==seqinfo[2].number) {
- if (j) osgbpb_write(filehandle, (byte *) " : ", 3);
- osgbpb_write(filehandle, (byte *) hexcode, 8);
- j=TRUE;
- }
- if (k==seqinfo[3].number) {
- if (j) osgbpb_write(filehandle, (byte *) " : ", 3);
- osgbpb_write(filehandle, (byte *) disassembly, dislength);
- if (dislength<50)
- osgbpb_write(filehandle, (byte *) " ", 50-dislength);
- j=TRUE;
- }
- }
- osgbpb_write(filehandle, (byte *) "\012", 1);
- }
- osfind_close(filehandle);
- osfile_set_type(filenameptr, 0xFFF);
- hourglass_off();
- }
-
-